<template>
  <div class="box1">
    <div class="top">
      <p class="title">男女比例</p>
      <p class="bg"></p>
    </div>
    <div class="sex">
      <div class="man"><span>男士</span><img src="../../images/man.png" /></div>
      <div class="woman">
        <span>女士</span><img src="../../images/woman.png" />
      </div>
    </div>
    <div class="rate">
      <p>男士58%</p>
      <p>女士42%</p>
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script setup lang="ts">
import * as echarts from "echarts";
import { onMounted, ref } from "vue";
let charts = ref();

onMounted(() => {
  let $echart = echarts.init(charts.value);
  $echart.setOption({
    title: {
      // text:'游客统计'
    },
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      data: ["男女比例"],
      show: false,
    },
    grid: { top: 0, right: 0, bottom: 0, left: 0 },
    series: [
      {
        type: "bar",
        data: [58],
        stack: "sex",
        barWidth: 20,
        itemStyle: {
          color: "blue",
          borderRadius: [15, 0, 0, 15],
        },
      },
      {
        type: "bar",
        data: [42],
        stack: "sex",
        barWidth: 20,
        itemStyle: {
          color: "pink",
          borderRadius: [0, 15, 15, 0],
        },
      },
    ],
  });
});
</script>

<style scoped lang="scss">
.box1 {
  background-color: #fff;
  margin-top: 10px;
  background: url(../../images/dataScreen-main-lb.png) no-repeat;
  background-size: 100% 100%;

  .top {
    .title {
      color: white;
      font-size: 20px;
      margin-left: 20px;
      margin-top: 10px;
    }

    .bg {
      width: 68px;
      height: 7px;
      background: url(../../images/dataScreen-title.png) no-repeat;
      background-size: 100% 100%;
      margin-top: 10px;
      margin-left: 20px;
    }
  }

  .sex {
    margin-top: 20px;
    display: flex;
    justify-content: center;

    .man {
      margin: 20px;
      width: 111px;
      height: 116px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      background: url(../../images/man-bg.png) no-repeat;

      span {
        color: white;
        position: relative;
        top: -17px;
      }
    }

    .woman {
      margin: 20px;
      width: 111px;
      height: 116px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      background: url(../../images/woman-bg.png) no-repeat;

      span {
        color: white;
        position: relative;
        top: -17px;
      }
    }
  }

  .rate {
    display: flex;
    justify-content: space-between;
    color: white;

    p:first-child {
      margin-left: 40px;
    }

    p:last-child {
      margin-right: 40px;
    }
  }

  .charts {
    height: 80px;
    margin: 0px 40px;
  }
}
</style>
